package com.ubs.training.server.aop;

import com.ubs.training.prod.server.service.LoggingService;
import com.ubs.training.server.dao.model.Product;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * User: xubuntu
 * Date: 8/24/12
 * Time: 11:57 AM
 * To change this template use File | Settings | File Templates.
 */
@Aspect
@Component
public class ProductAdvice extends AbstractLoggingAdvice {


    @After("execution(* *.saveProduct(..)) && args(obj2save)")
    public void processSave(Object obj2save) {
        svc.logEvent("AOP Saved product:" + obj2save.toString());
    }

    @After("execution(* *.deleteProduct(..)) && args(obj2save)")
    public void processDelete(Object obj2save) {
        svc.logEvent("AOP Deleted product:" + obj2save.toString());
    }

    @After("execution(* *.getProductById(..)) && args(obj2save)")
    public void processGetById(Object obj2save) {
        svc.logEvent("AOP Requested product with id=" + obj2save.toString());
    }

}



